# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ttyd
pkgver=1.6.1
pkgrel=0
pkgdesc="Share your terminal over the web"
url="https://tsl0922.github.io/ttyd"
arch="all"
license="MIT"
# Note: vim is needed for tool xxd.
makedepends="cmake json-c-dev bsd-compat-headers openssl-dev libwebsockets-dev
	vim zlib-dev libuv-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/tsl0922/ttyd/archive/$pkgver.tar.gz
	fix-cmake.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=TRUE \
		$CMAKE_CROSSOPTS .
	make -C build
}

check() {
	./build/ttyd --version
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="42fbff479e05dbaab94c8c83180f4ec98b8efe0af2f853e5c9317a84a5a2d46b7fc53308dccfeeea92793f05183a29e29428d2ba62a2a954c1b04335863082b0  ttyd-1.6.1.tar.gz
c489436c976c0a598763d3ebedcd42a7b3715b2c07967d74aaaad1fca345f85699f78ca3b62f0d810da0a1c91e868b8011cd3f9b62b5d5ad0a6185a8c5b6075f  fix-cmake.patch"
